﻿using System;
using System.Activities;
using System.Collections.Generic;
using KPIS.GERP.SERVICE.Model;

namespace KPIS.GERP.SERVICE.WorkflowService.CodeActivity
{
    #region [Pe]
    public class CreateAbsenceTaskActivity : System.Activities.CodeActivity
    {
        //public InArgument<int> TaskAbsenceTypeSeq { get; set; }
        //public InArgument<int> TaskRequesterEmpSeq { get; set; }
        public OutArgument<Guid> wf_InstantID { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            Guid instanceId = context.WorkflowInstanceId;
            context.SetValue(wf_InstantID,instanceId);
        }
    } 
    #endregion [Pe]

    public sealed class Select_HrmPsAbsence : CodeActivity<List<hrm_ps_absence>>
    {
        public InArgument<string> in_absence_seq { get; set; }
        public InArgument<string> in_absence_type_seq { get; set; }
        public InArgument<string> in_emp_seq { get; set; }
        public InArgument<string> in_bgm_year { get; set; }

        /// <summary>
        /// set True for join this object
        /// </summary>
        public InArgument<bool> in_IsGetHrmPsAbsenceType { get; set; }
        /// <summary>
        /// set True for join this object
        /// </summary>
        public InArgument<bool> in_IsGetHrmPsEmployee { get; set; }

        protected override List<hrm_ps_absence> Execute(CodeActivityContext context)
        {
            List<hrm_ps_absence> list = new DAL.Absence().GetHrmPsAbsence(
                in_absence_seq.Get(context)
                , in_absence_type_seq.Get(context)
                , in_emp_seq.Get(context)
                , in_bgm_year.Get(context)
                , in_IsGetHrmPsAbsenceType.Get(context)
                , in_IsGetHrmPsEmployee.Get(context));
            return list;
        }
    }

    public sealed class Select_SummaryHrmPsAbsence : CodeActivity<List<summary_hrm_ps_absence>>
    {
        public InArgument<string> in_absence_type_seq { get; set; }
        public InArgument<string> in_emp_seq { get; set; }
        public InArgument<string> in_bgm_year { get; set; }

        protected override List<summary_hrm_ps_absence> Execute(CodeActivityContext context)
        {
            List<summary_hrm_ps_absence> list = new DAL.Absence().GetSummaryHrmPsAbsence(
                in_absence_type_seq.Get(context)
                , in_emp_seq.Get(context)
                , in_bgm_year.Get(context));
            return list;
        }
    }

    public sealed class Select_HrmPsAbsenceType : CodeActivity<List<hrm_ps_absence_type>>
    {
        public InArgument<string> in_absence_type_seq { get; set; }

        protected override List<hrm_ps_absence_type> Execute(CodeActivityContext context)
        {
            List<hrm_ps_absence_type> list = new DAL.Absence().GetHrmPsAbsenceType(in_absence_type_seq.Get(context));
            return list;
        }
    }

    public sealed class Insert_HrmPsAbsence : CodeActivity<string>
    {
        public InArgument<string> in_absence_type_seq { get; set; }
        public InArgument<string> in_bgm_year { get; set; }
        public InArgument<string> in_emp_seq { get; set; }
        public InArgument<DateTime> in_start_date { get; set; }
        public InArgument<string> in_start_time { get; set; }
        public InArgument<DateTime> in_end_date { get; set; }
        public InArgument<string> in_end_time { get; set; }
        public InArgument<string> in_day_count { get; set; }
        public InArgument<string> in_contact_address { get; set; }
        public InArgument<string> in_remarks { get; set; }
        public InArgument<string> in_record_status { get; set; }
        public InArgument<string> in_created_by { get; set; }
        public InArgument<string> in_description { get; set; }
        public InArgument<string> in_request_title { get; set; }

        protected override string Execute(CodeActivityContext context)
        {
            return new DAL.Absence().InsertHrmPsAbsence(
                in_absence_type_seq.Get(context)
                , in_bgm_year.Get(context)
                , in_emp_seq.Get(context)
                , in_start_date.Get(context)
                , in_start_time.Get(context)
                , in_end_date.Get(context)
                , in_end_time.Get(context)
                , in_day_count.Get(context)
                , in_contact_address.Get(context)
                , in_remarks.Get(context)
                , in_record_status.Get(context)
                , in_created_by.Get(context)
                , in_description.Get(context)
                , in_request_title.Get(context));
        }
    }

    public sealed class Update_HrmPsAbsence : System.Activities.CodeActivity
    {
        [RequiredArgument]
        public InArgument<string> in_absence_seq { get; set; }
        public InArgument<string> in_absence_type_seq { get; set; }
        public InArgument<string> in_bgm_year { get; set; }
        public InArgument<string> in_emp_seq { get; set; }
        public InArgument<DateTime> in_start_date { get; set; }
        public InArgument<string> in_start_time { get; set; }
        public InArgument<DateTime> in_end_date { get; set; }
        public InArgument<string> in_end_time { get; set; }
        public InArgument<string> in_day_count { get; set; }
        public InArgument<string> in_contact_address { get; set; }
        public InArgument<string> in_remarks { get; set; }
        public InArgument<string> in_record_status { get; set; }
        public InArgument<string> in_updated_by { get; set; }
        public InArgument<string> in_description { get; set; }
        public InArgument<string> in_request_title { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            new DAL.Absence().UpdateHrmPsAbsence(
                in_absence_seq.Get(context)
                , in_absence_type_seq.Get(context)
                , in_bgm_year.Get(context)
                , in_emp_seq.Get(context)
                , in_start_date.Get(context)
                , in_start_time.Get(context)
                , in_end_date.Get(context)
                , in_end_time.Get(context)
                , in_day_count.Get(context)
                , in_contact_address.Get(context)
                , in_remarks.Get(context)
                , in_record_status.Get(context)
                , in_updated_by.Get(context)
                , in_description.Get(context)
                , in_request_title.Get(context));
        }
    }

    public sealed class UpdateStatus_HrmPsAbsence : System.Activities.CodeActivity
    {
        [RequiredArgument]
        public InArgument<string> in_absence_seq { get; set; }

        [RequiredArgument]
        public InArgument<string> in_record_status { get; set; }
        public InArgument<string> in_updated_by { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            new DAL.Absence().UpdateStatusHrmPsAbsence(
                in_absence_seq.Get(context)
                , in_record_status.Get(context)
                , in_updated_by.Get(context));
        }
    }

    public sealed class Insert_HrmPsAbsenceType : CodeActivity<string>
    {
        public InArgument<string> in_absence_type_name { get; set; }
        public InArgument<string> in_remarks { get; set; }
        public InArgument<string> in_record_status { get; set; }
        public InArgument<string> in_created_by { get; set; }

        protected override string Execute(CodeActivityContext context)
        {
            return new DAL.Absence().InsertHrmPsAbsenceType(
                in_absence_type_name.Get(context)
                , in_remarks.Get(context)
                , in_record_status.Get(context)
                , in_created_by.Get(context));
        }
    }

    public sealed class Update_HrmPsAbsenceType : System.Activities.CodeActivity
    {
        [RequiredArgument]
        public InArgument<string> in_absence_type_seq { get; set; }
        public InArgument<string> in_absence_type_name { get; set; }
        public InArgument<string> in_remarks { get; set; }
        public InArgument<string> in_record_status { get; set; }
        public InArgument<string> in_updated_by { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            new DAL.Absence().UpdateHrmPsAbsenceType(
                in_absence_type_seq.Get(context)
                , in_absence_type_seq.Get(context)
                , in_remarks.Get(context)
                , in_record_status.Get(context)
                , in_updated_by.Get(context));
        }
    }

    public sealed class UpdateStatus_HrmPsAbsenceType : System.Activities.CodeActivity
    {
        [RequiredArgument]
        public InArgument<string> in_absence_type_seq { get; set; }

        [RequiredArgument]
        public InArgument<string> in_record_status { get; set; }
        public InArgument<string> in_updated_by { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            new DAL.Absence().UpdateStatusHrmPsAbsenceType(
                in_absence_type_seq.Get(context)
                , in_record_status.Get(context)
                , in_updated_by.Get(context));
        }
    }

}
